#include <iostream>
#include<functional>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
string s1;
class Solution {
    vector<int> s1;
public:
    int my_pow(int n)
    {
        if(!n)
        {
            return 1;
        }
        return 10 * my_pow(n - 1);
    }
    void put(int num)
    {
        if(num < 10)
        {
            s1.push_back(num);
            return;
        }
        s1.push_back(num % 10);
        put(num / 10);
    }
    int splitNum(int num) {
        put(num);
        sort(s1.begin(),s1.end());
        int num1 = 0;
        int num2 = 0;
        int ret = 0;
        int tem = 0;
        if(s1.size() % 2)
        {
            ret = s1.size() / 2  ;
            tem = s1.size() - ret ;
            ret--;
            tem--;
        }
        else{
            ret = tem = s1.size() /2 - 1;
        }
        for(int j = 0;j < s1.size();j++)
        {
            cout << j << endl;
            if(j % 2)
            {
                num1 += s1[j] * my_pow(ret--);
            }
            else
            {
                //cout << ret << endl;
                num2 += s1[j] * my_pow(tem--);
                
            }
        }
        return  num1 + num2;
    }
};
int main() {
    
    int i = Solution().splitNum(687);
    return 0;
}
// 64 位输出请用 printf("%lld")